<template>

</template>

<script>
    export default {
        name: "Manager",
        data() {
            return {
                user: JSON.parse(localStorage.getItem('xm-user') || '{}'),
            }
        },
        created() {
            if (!this.user.id) {
                this.$router.push('/login')
            }
        },
        methods: {
            updateUser() {
                this.user = JSON.parse(localStorage.getItem('xm-user') || '{}')   // 重新获取下用户的最新信息
            },
            goToPerson() {
                if (this.user.role === 'ADMIN') {
                    this.$router.push('/adminPerson')
                }
                if (this.user.role === 'TEACHER') {
                    this.$router.push('/teacherPerson')
                }
                if (this.user.role === 'STUDENT') {
                    this.$router.push('/studentPerson')
                }

            },
            logout() {
                localStorage.removeItem('xm-user')
                this.$router.push('/login')
            }
        }
    }
</script>

<style scoped>
    @import "@/assets/css/manager.css";
</style>
